import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sgy_flutter/ble/ble_manager.dart';
import 'package:sgy_flutter/extensions/get.dart';
import 'package:sgy_flutter/gen/assets.gen.dart';
import 'package:sgy_flutter/page/detail/logic.dart';
import 'package:sgy_flutter/page/detail/widget/ble_state_view.dart';
import 'package:sgy_flutter/page/detail/widget/ble_stream_view.dart';

import '../widget/device_data_view.dart';

class DlsSingleCenterView extends GetView<DetailLogic> {
  const DlsSingleCenterView({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        border: Border.all(
          width: 0,
          color: Get.theme.primaryColor,
        ),
        color: Get.theme.primaryColor,
      ),
      child: // 功率,踏频
      Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(28), topRight: Radius.circular(28)),
          border: Border(
              bottom: BorderSide(color: Get.theme.primaryColor, width: 6)),
        ),
        padding: EdgeInsets.only(top: 24, bottom: 10, left: 12, right: 12),
        child: BleStreamView(
            bleManager: controller.bleManager,
            builder: (connected, data) {
              return Row(
                // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  DeviceDataView(
                      imagePath: Assets.image.iconLightning.path,
                      label: "功率/W".tr,
                      value:
                      "${connected && data?.power != null ? data?.power : '--'}"),
                  Container(
                    width: 2,
                    color: Get.theme.dividerColor,
                    height: 60,
                  ),
                  DeviceDataView(
                      imagePath: Assets.image.iconFrequency.path,
                      label: "踏频/RPM".tr,
                      value:
                      "${connected && data?.cadence != null ? data?.cadence : '--'}"),
                ],
              );
            },
            stream: controller.bleManager.dlsUploadModel),
      ),
    );
  }


}
